
@extends('master/master_index')

@section('title')
    <title>文章列表</title>
@endsection

@section('css')
    <link rel="stylesheet" type="text/css" href="{{asset('home/css/Topic_UserCenter.css')}}">
@endsection

@section('content')
        <div class="topic_list">
            <div class="msg_top">
                <ul>
                    <li ><a class="cl_a" href="{{url('section_list')}}/section={{$section_id}}/all">全部</a></li>
                    <li><a class="cl_a" href="{{url('section_list')}}/section={{$section_id}}/best">精华</a></li>
                    <li><a class="cl_a" href="{{url('section_list')}}/section={{$section_id}}/reply">评论</a></li>
                    <li><a class="cl_a" href="{{url('section_list')}}/section={{$section_id}}/vote">点赞</a></li>
                    <li><a class="cl_a" href="{{url('section_list')}}/section={{$section_id}}/time">时间</a></li>
                </ul>
            </div>
            <ul class="msg">

            </ul>
            <div class="load_all">
                加载完毕~~
            </div>
        </div>
@endsection

@section('js')
<script type="application/javascript">
        (function (window,$) {
            var message={
                isLoadAll:false,
                pn:1,
                init:function () {
                    this.addPage()
                    var self = this;
                    $(window).on('scroll',function () {
                        if (($(window).height()+$(window).scrollTop())>=$(document).height()){
                            if(!self.isLoadAll){
                                self.addPage();
                            }
                        }
                    });
                },
                addPage:function() {
                    var getUrl='{{url('section_list_class_add')}}';
                    var section_id='{{$section_id}}';
                    var sec_class='{{$class}}';
                    $.ajax({
                        type: 'POST',
                        url: getUrl,
                        data: {pn: this.pn,id:section_id,sec_class:sec_class},
                        Type: 'json',
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                        },
                        success: function (respond) {
                            $('.msg').append(respond);
                            if (respond==''){
                                $('.load_all').slideDown();
                            }
                        }
                    });
                    this.pn++;
                    }
                };
            message.init();
        })(window,jQuery);
</script>
@endsection